import {useState, memo} from 'react'; // 导入useState和memo
import {View, Button, Text} from 'react-native';

export default function App() {
  const [num, setNum] = useState(0);
  return (
    <View>
      <Button title={num.toString()} onPress={() => setNum(num + 1)} />

      {/* 修改父组件的状态， 也会让子组件  重新创建  浪费性能 memo函数来优化 */}
      <NewMemoSon />
    </View>
  );
}

const Son = () => {
  console.log('son 创建');
  return (
    <View>
      <Text>Son</Text>
    </View>
  );
};

const NewMemoSon = memo(Son);
